package zyx20230706;

import java.awt.*;

public class Shape {
    public int x1,x2,x3,x4,y1,y2,y3,y4;
    public String name;
    public Color color;

    public void drawShape(Graphics g){
        g.setColor(color);
        switch (name){
            case "直线":
                g.drawLine(x1,y1,x2,y2);
                break;
            case "三角形":
                g.drawLine(x1, y1, x3, y3);
                g.drawLine(x1, y1, x2, y2);
                g.drawLine(x2, y2, x3, y3);
                break;
            case "矩形":
                g.drawRect(Math.min(x1,x2),Math.min(y1,y2),Math.abs(x1-x2),Math.abs(y1-y2));
                break;
            case "圆":
                g.drawOval(Math.min(x1,x2),Math.min(y1,y2),Math.abs(x1-x2),Math.abs(y1-y2));
                break;
            case "铅笔":
                g.drawLine(x1, y1, x4, y4);
                break;
        }
    }
}
